#include <stdio.h>
#include <conio.h>
int hoanhao(int n)
{

    int i,s=0;
    for(i=1;i<=n/2;i++)
        if(n%i==0)s+=i;
    if(s==n) return 1;
    return 0;
}
main()
{
    int n,i,a[100];
    FILE *f;
    if(!freopen("vd1.inp","r",stdin))
     return 0;
    if(!freopen("vd2.out","w",stdout))
        return 0;
    scanf("%d",&n);
    i=0;
    while(i!=n)
    {
        scanf("%d",&a[i]);
        i++;
    }
    i=0;
    while(i!=n)
    {
        if(hoanhao(a[i]))
        {
            printf("%d\n",a[i]);
        }
        i++;

    }
}
